package cn.weekimwee.firstlineofcodeforkotlin

import android.os.Bundle
import android.widget.ArrayAdapter
import cn.weekimwee.firstlineofcodeforkotlin.unit10.Unit10Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit11.Unit11Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit12.Unit12Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit2.FirstActivity
import cn.weekimwee.firstlineofcodeforkotlin.unit3.ProgressBarActivity
import cn.weekimwee.firstlineofcodeforkotlin.unit4.Unit4Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit5.Unit5Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit6.Unit6Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit7.Unit7Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit8.Unit8Activity
import cn.weekimwee.firstlineofcodeforkotlin.unit9.Unit9Activity
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast

class MainActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val title = arrayListOf(
                "Unit 1 ",
                "Unit 2 ",
                "Unit 3 ",
                "Unit 4 ",
                "Unit 5 ",
                "Unit 6 ",
                "Unit 7 ",
                "Unit 8",
                "Unit 9",
                "Unit 10",
                "Unit 11",
                "Unit 12",
                "Unit 13"
        )
        listView.adapter = ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, title)
        listView.setOnItemClickListener { _, _, position, _ ->
            when (position) {
                0 -> toast(resources.getString(R.string.unit_one_nothing))
                1 -> startActivity<FirstActivity>()
                2 -> startActivity<ProgressBarActivity>()
                3 -> startActivity<Unit4Activity>()
                4 -> startActivity<Unit5Activity>()
                5 -> startActivity<Unit6Activity>()
                6 -> startActivity<Unit7Activity>()
                7 -> startActivity<Unit8Activity>()
                8 -> startActivity<Unit9Activity>()
                9 -> startActivity<Unit10Activity>()
                10 ->startActivity<Unit11Activity>()
                11 -> startActivity<Unit12Activity>()
                12 -> toast(resources.getString(R.string.unit_13))
            }
        }
    }
}
